package ch11;

import java.util.Enumeration;
import java.util.Properties;

class _22_PropertiesEx {
	public static void main(String[] args) throws Exception {
		Properties prop = new Properties();

		prop.setProperty("timeout", "30");
		prop.setProperty("language", "kr");
		prop.setProperty("size", "10");
		prop.setProperty("capacity", "10");

		@SuppressWarnings("rawtypes")
		Enumeration e = prop.propertyNames();

		while (e.hasMoreElements()) {
			String element = (String) e.nextElement();
			System.out.println(element + "=" + prop.getProperty(element));
		}
		System.out.println();
		/*
		capacity=10
		size=10
		timeout=30
		language=kr
		*/
		
		prop.setProperty("size", "20"); 
		System.out.println("size=" + prop.getProperty("size")); // size=20
		System.out.println("capacity=" + prop.getProperty("capacity", "20")); // capacity=10
		System.out.println("loadfactor=" + prop.getProperty("loadfactor", "0.75")); // loadfactor=0.75

		System.out.println(prop); // {capacity=10, size=20, timeout=30, language=kr}
		prop.list(System.out);
		/*
		-- listing properties --
		capacity=10
		size=20
		timeout=30
		language=kr
		*/
	}
}